package com.itheima.app.controller;

import com.itheima.app.manager.SettingManager;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingController {

    @Autowired
    SettingManager settingManager;

    //查询用户通用设置
    @GetMapping("/users/settings")
    public ResponseEntity findSetting() {
        return settingManager.findSetting();
    }

    //设置陌生人问题
    @PostMapping("/users/questions")
    public void setQuestion(@RequestBody Map<String, String> map) {
        //1.获取提交过来的问题
        String content = map.get("content");

        //2.调用manager完成新增或者修改操作
        settingManager.setQuestion(content);
    }

    //设置推送通知
    @PostMapping("/users/notifications/setting")
    public void setNotification(@RequestBody Notification param) {
        settingManager.setNotification(param);
    }

    //查询黑名单列表
    @GetMapping("/users/blacklist")
    public ResponseEntity findBlackListByPage(
            @RequestParam(value = "page",defaultValue = "1")Integer pageNum,
            @RequestParam(defaultValue = "10")Integer pageSize){
        return settingManager.findBlackListByPage(pageNum,pageSize);
    }

    //移出黑名单
    @DeleteMapping("/users/blacklist/{blackId}")
    public void deleteBlackList(@PathVariable Long blackId){
        settingManager.deleteBlackList(blackId);
    }
}